﻿//using NATS.Client.Core;

//using System.Buffers;

//namespace Acl.Messages.Impl;

//internal class NatsSerializerAdapter : INatsSerializer
//{
//    private IDistributionMessageSerializer _messageSerializer;

//    public NatsSerializerAdapter(IDistributionMessageSerializer messageSerializer) => _messageSerializer = messageSerializer;

//    public INatsSerializer? Next => NatsDefaultSerializer.Default;

//    public T? Deserialize<T>(in ReadOnlySequence<byte> buffer) => _messageSerializer.Deserialize<T>(buffer);

//    public object? Deserialize(in ReadOnlySequence<byte> buffer, Type type) => _messageSerializer.Deserialize(buffer, type);

//    public int Serialize<T>(NATS.Client.Core.ICountableBufferWriter bufferWriter, T? value) => _messageSerializer.Serialize<T>(new BufferWriterAdapter(bufferWriter), value);

//    private struct BufferWriterAdapter : Acl.Messages.ICountableBufferWriter
//    {
//        private NATS.Client.Core.ICountableBufferWriter _bufferWriter;

//        public BufferWriterAdapter(NATS.Client.Core.ICountableBufferWriter bufferWriter) => _bufferWriter = bufferWriter;

//        public int WrittenCount => _bufferWriter.WrittenCount;

//        public void Advance(int count) => _bufferWriter.Advance(count);

//        public Memory<byte> GetMemory(int sizeHint = 0) => _bufferWriter.GetMemory(sizeHint);

//        public Span<byte> GetSpan(int sizeHint = 0) => _bufferWriter.GetSpan(sizeHint);
//    }
//}